<?php 
	$table = $this->table;
	$table_title = $table->getTable_title();
	
	$table_data = $table->getTable_data();
	$table_header = $table->getTable_header();
	
	$add_link = $table->getAdd_link();
	$edit_link = $table->getEdit_link();
	$delete_link = $table->getDelete_link();
	$more_links = $table->getMore_links();
	$custom_fields = $table->getCustom_fields();	
	
	$page = $table->getPage();
	$line_per_page = $table->getLine_per_page();
	
	$counter = 0;
	
	$table_translate = $this->table_translate ? $this->table_translate : array();
	//Zend_Debug::dump($table_translate);
?>

<!-- データを一覧い表示するためのビュー -->
<form class="block-content form" id="table_form" method="post" action="">
	<h1>
		<?php echo $table_title;?>
		<?php if($add_link):?>
			<a href="<?php echo $add_link;?>"><img src="/images/icons/fugue/plus-circle-blue.png" width="16" height="16"> 追加</a>
		<?php endif;?>
		<?php if($table_title == "予約参照"):?>
			<a href="/admin/order/penalty"><img src="/images/icons/fugue/plus-circle-blue.png" width="16" height="16">ペナルティ</a>
		<?php endif;?>
	</h1>
	
	<!-- テーブルページング -->
	<?php include 'table_pager.phtml';?>
	
	<div class="no-margin"><table class="table" cellspacing="0" width="100%">
	
		<thead>
			<tr>
				<th class="black-cell"><span class="success"></span></th>
				<?php foreach ($table_header as $key => $value_arr):?>
					<th scope="col">
						<?php if($value_arr[1]):?>
							<span class="column-sort">
								<a href="#" title="Sort up" class="sort-up"></a>
								<a href="#" title="Sort down" class="sort-down"></a>
							</span>
						<?php endif;?>
						<?php echo $value_arr[0];?>
					</th>
				<?php endforeach;?>
				<th scope="col" class="table-actions">アクション</th>
				<?php if($table_title == "ユーザ"):?>
					<th scope="col" class="table-control">承認</th>	
				<?php endif;?>
			</tr>
		</thead>
		
		<tbody>
			<?php foreach ($table_data as $row):?>
					<tr>
						<th scope="row" class="table-check-cell"><input type="checkbox" name="selected[]" id="table-selected-1" class="delCheckbox" value="<?php echo $row['id']?>"></th>
						<?php foreach ($table_header as $key => $value):?>
							<?php if(@$table_translate[$key]):?>
								<td><?php echo $table_translate[$key][$row[$key]]?></td>
							<?php else:?>
								<td><?php echo @$row[$key]?></td>
							<?php endif;?>
						<?php endforeach;?>
						
						<td class="table-actions">
							<?php if ($edit_link):?>
								<a href="<?php echo $edit_link . "?edit_id=" . $row['id']?>" title="Edit" class="with-tip"><img src="/images/icons/fugue/pencil.png" width="16" height="16"></a>
							<?php endif;?>
							<?php if($delete_link):?>
								<a href="#" onclick="doDeleteRow('<?php echo $delete_link?>', <?php echo $row['id']?>);return false;" title="Delete" class="with-tip"><img src="/images/icons/fugue/cross-circle.png" width="16" height="16"></a>
							<?php endif;?>
							<?php if ($table->getMore_links()):?>
								<?php foreach ($table->getMore_links() as $key => $value):?>
									<?php if($table_title == "予約参照"):?>
										<?php $current_time = date("Y-m-d H:i:s");?>
										<?php if($row['start_time'] > $current_time && $row['status'] != STATUS_CANCELED):?>
											<a href="<?php echo $key . "?order_id=" . $row['id']?>" title="<?php echo $value?>" class="with-tip">
												<?php echo $value?>
											</a>
										<?php endif;?>
									<?php else :?>
										<a href="<?php echo $key . "?order_id=" . $row['id']?>" title="<?php echo $value?>" class="with-tip">
											<?php echo $value?>
										</a>
									<?php endif;?>
								<?php endforeach;?>
							<?php endif;?>
						</td>
						
						<?php if($table_title == "ユーザ"):?>
						<td>
							<ul class="controls-buttons">
								<?php if($row['status'] == STATUS_WAITING):?>
									<li>
										<a href="" onclick="doConfirm(this, <?php echo $row['id']?>);return false;">
											<img src="/images/icons/fugue/tick-circle-blue.png" width="16" height="16">
											承認
										</a>
									</li>
								<?php endif;?>
							</ul>
						</td>
						<?php endif;?>
					</tr>
			<?php endforeach;?>
		</tbody>
	</table></div>
	
	<ul class="message no-margin">
		<?php 
			$table = $this->table;
			$data_count = $table->getData_count();
			$page = $table->getPage();
			
			$start = $data_count > 0 ? ($page - 1) * 10 + 1 : 0;
			$end = $start + 9 < $data_count ? $start + 9 : $data_count; 
		?>
		<li><?php echo $start . " - " . $end ?> の<?php echo $data_count?>結果</li>
	</ul>
	
	<div class="block-footer">
		<img src="/images/icons/fugue/arrow-curve-000-left.png" width="16" height="16" class="picto"> 
		<a href="#" class="button" onclick="$('.delCheckbox').attr('checked', true);return false;">すべて</a> 
		<a href="#" class="button" onclick="$('.delCheckbox').attr('checked', false);return false;">すべて解除</a>
		<span class="sep"></span>
		
		<?php echo $this->formSelect("table-action", NULL, NULL, $table->getTable_multi_actions());?>
		<button type="button" id="table_multi_action">運用</button>
	</div>
		
</form>

<!-- テーブルデータを操作するときのメッセージ -->
<div id="dialog-confirm" style="display:none;text-align: center;" title="削除">
	<?php echo $this->translate("データを作成してもよろしいでしょうか。");?>
</div>

<div id="dialog-please-chose-item" style="display:none;text-align: center;" title="一つの項目を選択してください。">
	<?php echo $this->translate("一つの項目を選択してください。");?>
</div>

<div id="dialog-delete-successful" style="display:none;text-align: center;" title="削除">
	<?php echo $this->translate("データが削除されました。");?>
</div>